// 获取全局应用程序实例对象
const app = getApp()

Page({
  data: {
    r_id: '',
    lists: []
  },
  onLoad: function () {
    //发起请求  
    var that = this;
    app.network.POST(
      'https://www.ausck.com/api/recharge_package',
      {
        params: {},
        success: function (res) {
          console.log()
          //拿到解密后的数据，进行代码逻辑
          that.setData({
            lists: res.data.data
          })


        },
        fail: function () {
          //失败后的逻辑  

        },
      })

  },
  radioChange: function (e) {
    this.setData({
      r_id: e.detail.value
    })
  },
  queren: function (e) {
    var that = this;
    var params = {
      openid: app.globalData.info.openid,
      r_id: that.data.r_id
    };
    app.network.POST(
      'https://www.ausck.com/api/recharge',
      {
        params: params,
        success: function (res) {
          //拿到解密后的数据，进行代码逻辑
          console.log(res.data.config)
          var info = res.data.config;

          wx.requestPayment({
            'timeStamp': info.timeStamp,
            'nonceStr': info.nonceStr,
            'package': info.package,
            'signType': 'MD5',
            'paySign': info.paySign,
            'success': function (res) {
              wx.navigateTo({
                url: '/pages/details/details',
              })
            },
            'fail': function (res) {
            }
          })
        },
        fail: function () {
          //失败后的逻辑  

        },
      })
  }
})